package com.example.demo.controlller;

import com.example.demo.pojo.Doc;
import com.example.demo.pojo.PageBean;
import com.example.demo.pojo.Result;
import com.example.demo.service.Docservice;
import com.example.demo.service.Impl.Docserviceimpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/doc")
public class Doccontroller {
    @Autowired
    Docservice docservice;

    /**
     * 医生页面查询所有数据
     * @return
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    //查询并返回一个名为Doc的实体类的列表
 public  Result queryAll(){
     List<Doc> Dlist=docservice.queryAll();
     return Result.success(Dlist);

 }

@RequestMapping("/delete")
    @ResponseBody
    public Result delete(String docid){
        docservice.delete(docid);
        return Result.success();
}



    @RequestMapping("/queryName")
    @ResponseBody
    //根据提供的名称参数查询数据库，并返回一个包含匹配记录的Doc实体列表
    public Result queryName(String name){
        List<Doc> list=docservice.queryName(name);
        return Result.success(list);
    }


@RequestMapping("/add")
    @ResponseBody
    public Result insert(@RequestBody Doc doc){
        docservice.insert(doc);
        return Result.success();
}


@RequestMapping("/update")
    @ResponseBody
    public Result update(@RequestBody Doc doc){
        docservice.update(doc);
        return Result.success();
}
@RequestMapping("/page1")
@ResponseBody
    public Result page(@RequestParam(defaultValue = "1")Integer page,@RequestParam(defaultValue = "10")Integer pageSize){
    PageBean pageBean=docservice.page(page,pageSize);
    return Result.success(pageBean);
}



}
